package priv.web.control;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import priv.web.util.ReviewJDBCUtil;

import com.alibaba.fastjson.JSON;

public class HahaHandler extends HttpServlet{

//	@Override
//	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
//			throws ServletException, IOException {
//		try {
//			List<Map<String, Object>> result = ReviewJDBCUtil.query("select * from food_order");
//			resp.setContentType("application/json;charset=utf-8");
//			resp.getWriter().print(JSON.toJSONString(result));
//		} catch (ClassNotFoundException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//	}
	
	
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			List<Map<String, Object>> result = ReviewJDBCUtil.query("select * from food_order");
			resp.setContentType("application/json;charset=utf-8");
			resp.getWriter().print(JSON.toJSONString(result));
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
}
